<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="/WEB-INF/taglib/c.tld" %>
<%@ taglib uri="/WEB-INF/taglib/fn.tld" prefix="fn" %>
<%    
String path = request.getContextPath();    
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";    
pageContext.setAttribute("basePath",basePath);    
%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8"/>
<title>i HelloWorld</title>
<base href="<%=basePath %>" />
<link rel="stylesheet" type="text/css" href="js/easyui/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="js/easyui/themes/icon.css"/>
<script type="text/javascript" src="js/jquery-2.0.3.js"></script>
<script type="text/javascript" src="js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/easyui/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/json2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $('#conditions').searchbox({
        searcher:function(value,name){
        	var item = $('#conditions').searchbox('menu').menu('findItem', name);
        	var obj={};
        	var key=item.name;
        	obj[key]=value;
        	$("#dg").datagrid("load",obj);
        },
        menu:'#mm'
    });
	
	$("#dg").datagrid({
		url:"admin/comment/query.do",
		fitColumns:true,
		toolbar: "#tb",
		method:"post",
		idField:"id",
		singleSelect:true,
		checkOnSelect:false,
		selectOnCheck:false,
		pagination:true,
		pageSize:20,
		pageList:[20,30,40],
		columns:[[
			 {field:"id",title:"标识码",checkbox:true,align:"center",width:100},
			 {field:"author",title:"评论人",align:"center",width:100},
			 {field:"content",title:"内容",align:"center",editor:"text",width:100},
			 {field:"articleName",title:"原文",align:"center",editor:"numberbox",width:100},
			 {field:"createDate",title:"时间",align:"center",editor:"text",width:100}
		]]
	});
});
function rmov(){
	var rows = $("#dg").datagrid('getChecked');
	var id="";
	for(var i=0;i<rows.length;i++){
		if(i!=rows.length-1){
			id=id+rows[i].id+",";
		}else{
			id=id+rows[i].id;
		}
	}
	$.post("admin/comment/delete.do",{ids:id},function(rs){
		if(rs.status){
			$('#dg').datagrid('reload');
		}
	});
	//var rowIndex = $("#dg").datagrid('getRowIndex',id);
	//$("#dg").datagrid('deleteRow', rowIndex);		
}
</script>
</head>

<body>
	<table id="dg"></table>
    <div id="tb">
    	<div style="display: inline-block;margin-right:50px;vertical-align: bottom;">
	    	<input id="conditions"></input>
	    	<div id="mm" style="width:120px">
	    		<div data-options="name:'article'">原文</div>
	   			<div data-options="name:'author'">评论人</div>
	    	</div>
    	</div>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="rmov()">删除</a>
    </div>
</body>
</html>